package org.mango.springboot.util.id;

import java.util.UUID;

/**
 * Created by meigang on 17/8/28.
 */
public class IdUtil {
    private static SnowflakeIdWorker snowflakeIdWorker = null;

    /**
     * 生成 uuid
     * @return
     */
    public static String genUuid(){
        String uuid = UUID.randomUUID().toString();
        uuid = uuid.replaceAll("-","");
        return uuid;
    }

    public static synchronized long genId() {
        if(snowflakeIdWorker == null) {
            snowflakeIdWorker = new SnowflakeIdWorker((long)0, (long)0);
        }

        return snowflakeIdWorker.nextId();
    }

}
